package com.ruoyi.ams.domain.vo;

import com.fasterxml.jackson.annotation.JsonInclude;

import com.ruoyi.common.core.domain.model.AmsAssetType;
import com.ruoyi.common.core.domain.model.AmsOwnAddress;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author yfkj
 */
@Data
@NoArgsConstructor
public class WxTreeSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long value;

    /** 节点名称 */
    private String text;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<WxTreeSelect> children;

    public WxTreeSelect(AmsOwnAddress address)
    {
        this.value = address.getAddressId();
        this.text = address.getName();

        if (address.getChildren() != null){
            this.children = address.getChildren().stream().map(WxTreeSelect::new).collect(Collectors.toList());
        }

    }
    public WxTreeSelect(AmsAssetType assetType)
    {
        this.value = assetType.getAssetTypeId();
        this.text = assetType.getAssetTypeName();

        if (assetType.getChildren() != null){
            this.children = assetType.getChildren().stream().map(WxTreeSelect::new).collect(Collectors.toList());
        }

    }
}
